package com.fan.gofast.compent;

import com.fan.gofast.constant.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class BusinessException extends RuntimeException {

    private ResultEnum resultEnum;

    private Integer errorCode;

    private String errorMessage;

    private String channelMessage;

    private Map<String, Object> errorData;

    public BusinessException(ResultEnum resultEnum) {
        super(resultEnum.message);
        this.resultEnum = resultEnum;
        this.errorCode = resultEnum.code;
        this.errorMessage = resultEnum.message;
    }

    public BusinessException(ResultEnum resultEnum, String msg) {
        super(msg);
        this.resultEnum = resultEnum;
        this.errorCode = resultEnum.code;
        this.errorMessage = resultEnum.message;
        this.channelMessage = msg;
    }

    public BusinessException(Integer errorCode, String msg) {
        super(msg);
        this.errorCode = errorCode;
        this.errorMessage = msg;
    }
}
